package typejump.commands;

import typejump.AnimationManager;
import typejump.Settings;
import typejump.TypeJump;
import typejump.engine.GameEngine;
import typejump.engine.OnGoingThing;
import typejump.objects.AttachableSparkles;
import typejump.objects.GameObject;
import typejump.objects.Sparkles;

public class DevSparkle implements TextCommand {

	Sparkles sparkles = null;
	
	@Override
	public boolean matches(String command) {
		return command.matches("dev sparkle(s?)( \\d+)?");
	}

	@Override
	public void act(String command) {
		if (sparkles != null) {
			sparkles.stopSparkling();
			sparkles = null;
			if (command.matches(".*? \\d+"))
				act(command);
			return;
		}
		
		int type = command.matches("dev sparkle(s?) \\d+?") ? Integer.parseInt(command.split(" ")[2]) : 0;
		
		switch (type) {
		case 1:
			sparkles = new AttachableSparkles(GameEngine.getPlayer(), AnimationManager.HEART, 0, AttachableSparkles.ATTACH_CENTER);
			sparkles.setSpawnRate(100);
			sparkles.setSpeedX(0, 50);
			sparkles.setSpeedY(0, 50);
			break;

		case 2:
			sparkles = new AttachableSparkles(GameEngine.getPlayer(), AnimationManager.SPARKLE_RAINBOW, 0,
					AttachableSparkles.ATTACH_LEFT | AttachableSparkles.ATTACH_CENTERY);
			sparkles.setSpawnRate(10000);
			sparkles.setLifetime(1);
			break;

		case 3:
			sparkles = new AttachableSparkles(GameEngine.getPlayer(), AnimationManager.SWAG_DROP, 0, AttachableSparkles.ATTACH_CENTER);
			sparkles.setSpawnRate(100);
			sparkles.setLifetime(0.5);
			sparkles.setSpeedX(0, 50);
			sparkles.setSpeedY(0, 50);
			break;
			
		default:
		case 0:
			sparkles = new AttachableSparkles(GameEngine.getPlayer(), AnimationManager.SPARKLE, 0);
			sparkles.setSpawnRate(1000);
			break;
		}
		
		GameEngine.addTextEffect("SPARKLES!", "dev");
		
		GameEngine.addEffect(sparkles);
	}

}
